﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using BioBooking.Data;

namespace BioBooking.Client.Screens.Elements
{
    /// <summary>
    /// Interaction logic for SeatPresenter.xaml
    /// </summary>
    public partial class SeatPresenter : UserControl
    {
        //ObservableCollection<SeatState> SeatStates;

        IRepository repository;

        private Showing showing;
        public Showing Showing
        {
            get 
            { 
                return showing; 
            }
            set
            {
                this.showing = value;
                this.DataContext = showing;
                //SeatStates = new ObservableCollection<SeatState>(this.showing.SeatStates);
                //SeatStates.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SeatStates_CollectionChanged);
                //this.DataContext = SeatStates;
            }
        }

        public SeatPresenter() : this(null)
        {
            InitializeComponent();
        }

        public SeatPresenter(Showing showing)
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                repository = Repository.GetRepository();
                if (showing != null)
                {
                    this.Showing = showing;
                }
            }
        }

        private void rectangle1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Border item = sender as Border;
            SeatState state = item.DataContext as SeatState;

            state.Locked = !state.Locked;

            ////int index = SeatStates.IndexOf(state);
            ////SeatStates[index].Locked = true;
        }
    }
}
